1. Interpretation of results

  The test program syncs with the 9918 (or similar) vertical interrupt. It
  does not consider any of the other interrupts in the V9938 or later.

  The results will probably be meaningless in any machine with separate clocks
  for the CPU and the VDP. Even in machines with a shared clock, there seem
  to be six possible phases between CPU and VDP, as demonstrated by the three
  different results obtained in the VG-8020/40 and the NMS-8250.

  All measurements are taken from the CPU (no hardware probes), therefore
  they all use the CPU clock as a basis.

  The program reports a screen with this layout:

    Screen mode: S
    Error code (0=no error): E
    Cycles/frame: F
    ACK works A cyc. after INT
    Bit 7 set B cyc. after INT
    ACK takes C to D cycles
    First fast wr. failure: G

  Where:
    F: total CPU cycles per frame.
    E: exit error code; a value of 0 means no error.
    Note: The value of F has been found to be stable in all tested computers,
    even in those with separate clocks. Cause is unknown.

    A: Number of ticks at which an interrupt may be acknowledged by reading
       the Status Register, relative to the interrupt, causing the interrupt
       line to go inactive. Negative means before the interrupt. It was
       negative in every tested VDP, but note that a positive value of up to
       19 cycles would allow any interrupt service routine to acknowledge it,
       due to the delay for the interrupt to trigger and for the fastest IN
       instruction to execute.
    B: Number of ticks, relative to the interrupt, at which the Status
       Register bit 7 starts being set. Negative means before the interrupt.
    C, D: Minimum and maximum number of cycles for interrupt acknowledgement,
       that is, from the I/O read of the Status Register to an INT being
       no longer triggered. D=-1 means from C up. Possible values of C,D are:
          0,2;  3,5;  6,10;  11,12;  13,13;  14,14;  15,15;  16,-1.
       I don't think software can distinguish finer results. Suggestions for
       how to perform a more fine-grained test are welcome.
    G: Number of ticks, relative to the interrupt, at which writing to VRAM
       at the fastest possible rate causes a write failure. A value equal to
       F (total CPU cycles per frame) means that every fast write succeeds.

  Example using one set of values obtained in the Philips VG-8020/40:

  E: 0
  - Error code: 0, meaning no error.
  F: 71364
  - 71364 cycles (T-states) per frame (typical in PAL machines).
  A: -5
  B: -3
  - If the status register is read 5 cycles before the interrupt, the
    interrupt is not triggered. This counts the exact cycle at which the
    I/O operation takes place, not the start of the instruction.
  - Bit 7 of the status register is set 3 cycles before the interrupt.
  - Note that when A < B, that leaves a gap in which, if the status port
    is read at a cycle >= A and < B, neither bit 7 of the Status Register
    will be set, nor will the interrupt trigger.
  C: 3
  D: 5
  - Once the int line goes low (active), it takes between 3 and 5 cycles
    inclusive (but we don't know how many exactly) for the interrupt to be
    blocked after being acknowledged. Note: Since the /INT line is sampled
    at the last cycle of each instruction, this probably means that at the
    hardware level, it takes between 2 and 4 cycles for this line to go high
    again.
  G: 27130
  - Writing to the VRAM at the fastest possible rate (faster than the VDP
    can handle) is guaranteed to succeed if performed during cycles 0 to
    27129 inclusive after the interrupt; the first time it will fail is
    27130 cycles after the interrupt. A value equal to F (71364 in this
    example) means that every fast write succeeds, no matter how many
    cycles after the interrupt.


2. Results for machines with synced clocks

  Philips VG-8020/40 (VDP: TMS9129NL):
    E: 0
    F: 71364
    G: 71364 for screen 0
    A, B, G: Varies between three possible tuples:
       -5, -4, 27130
       -5, -3, 27130
       -4, -3, 27131
      These values of G are for screens 1, 2, 3; for screen 0 it's always
      71364. The values of A, B, G are consistent between runs or soft resets
      (DEFUSR=0); they only vary between hard resets (RESET button) or power
      cycles.
    C, D: 3, 5

    Two possible explanations for the different A,B,G values are:
    - Variation in the phase between VDP and CPU.
    - Randomness in the initialization of the internal 2-bit "CPU" counter
      in the VDP (see US Patent 4,243,984).


  Philips NMS-8250 (VDP: V9938):
    E: 0
    F: 71364 (59736 after entering VDP(10)=0).
    A, B, C, D values observed:
      -6, -3, 3, 5
      -6, -2, 3, 5
      -6, -3, 6, 10
      -6, -2, 6, 10
    G: 4 in screen 0, 8 in screen 1-3. Not affected by NTSC mode.

    Generally consistent between runs but not between hard boots, as in the
    VG-8020/40. One inconsistency between runs was possibly found
    (-6 -3 3 5 vs -6 -2 3 5), but not sure.


3. Results for machines with separate clocks

  Sony HB-10P (VDP: T6950, separate clocks):
    E: 0
    F: 71745
    A, B: Variable. Minimum A observed was -15; maximum -1. Minimum B observed
          was -16; maximum -1. abs(A-B) was always 0 or 1, with both A<B and
          A>B observed. They are tested separately, therefore it's possible
          that they always occur at the same cycle.
          The values became smaller with longer power-on times, suggesting
          that the cause is temperature.
    C, D: 3, 5
    G: not tested yet


4. Results for openMSX (current master as of Feb 10 2020)

  All machines:
     E: 0
     F: 71364/59736 (PAL/NTSC)
     A, B: 0, 0
     C, D: 0, 2
     G: 71364/59736 in screen 0, 27588/15960 in screens 1-3 (PAL/NTSC)
